class CreateSubjects < ActiveRecord::Migration
  def self.up
    create_table :subjects do |t|
      t.text :name
      t.string :abbreviation
      t.string :code
      t.references :educational_plan
      t.integer :term_number
      t.integer :credits
      t.boolean :is_required, :default => true
      t.boolean :optional_stub, :default => false
      t.text :info
      t.text :bibliography

      t.timestamps
    end
    add_index(:subjects, :code, :unique => true)
    add_index(:subjects, :name, :unique => false)
  end

  def self.down
    remove_index(:subjects, :column => :code)
    remove_index(:subjects, :column => :name)
    drop_table :subjects
  end
end
